package com.dwb.controller;

import com.dwb.dto.SJishiDto;
import com.dwb.entity.SJishi;
import com.dwb.result.Result;
import com.dwb.service.TechnicianService;
import com.dwb.vo.PageVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Author manke
 * @Date 2020/6/23 15:25
 * @Version 0.0.1
 */
@RestController
@Api(value = "technician", description = "技师控制器")
@RequestMapping("/technician")
public class TechnicianController {
    @Autowired
    private TechnicianService technicianService;

    @ApiOperation(value = "add", notes = "技师添加")
    @PostMapping("/add")
    public Result<Integer> add(@RequestBody SJishi technician) {
        technicianService.insert(technician);
        return Result.newSuccess();
    }


    /**
     * 技师审核
     * @param parameters
     * @return
     */
    @ApiOperation(value = "updateState",notes = "技师审核")
    @PostMapping("/updateState")
    public Result<String> updateState(@RequestBody Map<String, String > parameters) {
        Result<String> result = Result.newSuccess();
        technicianService.updateState(parameters);
        return result;
    }

    /**
     * 分页/按条件过滤 获取技师列表
     *
     * @param parameters
     * @return
     */
    @ApiOperation(value = "getList")
    @PostMapping("/getList")
    public Result<PageInfo<SJishi>> getList(@RequestBody Map<String, Object> parameters) {
        Result<PageInfo<SJishi>> result = Result.newSuccess();
        PageInfo<SJishi> list = technicianService.getList(parameters);
        result.setDataMap(list);
        return result;
    }

    /**
     * 获取技师详情信息
     *
     * @return
     */
    @ApiOperation(value = "getInfo")
    @PostMapping("/getInfo")
    public Result<Map<String, Object>> getInfo(@RequestBody Map<String, String> parameters) {
        Result<Map<String, Object>> result = Result.newSuccess();
        Map<String, Object> info = technicianService.getInfo(parameters);
        result.setDataMap(info);
        return result;
    }

    /**
     * 根据主键更新技师信息
     * @param parameters
     * @return
     */
    @ApiOperation(value = "updateInfo")
    @PostMapping("/updateInfo")
    public Result<String> updateInfo(@RequestBody Map<String, Object> parameters) {
        technicianService.updateInfo(parameters);
        return Result.newSuccess();
        //

    }


}
